package data.model;

import java.util.Date;
import data.model.Need;
import data.model.Truck;

public class Event {

    public static final int NO_ID = -1;

    private int    id;
    private Truck  T;
    private String nom;
    private Need   need;
    private String client;
    private Date   debut;
    private Date   fin;


    //constructors
    public Event()
    {}
    
    public Event(String cl, long weight, long mp, long price, Date D, Date F){
	need = new Need();
	this.client = cl;
	setWeight(weight);
	setMp(mp);
	setPrice(price);	
	this.debut  = D;
	this.fin    = F;


    }

    public Event(String cl, Need be, Date D, Date F) {
	this.client = cl;
	this.need   = be;
	this.debut  = D;
	this.fin    = F;
    }

    //getters

    public int getId(){
	return id;
    }

    public String getClient() {
	return this.client;
    }

    public Need getNeed() {
	return this.need;
    }

    public Date getDebut() {
	return this.debut;
    }

    public Date getFin() {
	return this.fin;
    }

    public long getMp(){
	return need.getMp();
    }

    public long getPoids(){
	return need.getWeight();
    }

    public long getPrix(){
	return need.getPrice();
    }

    public Truck getTruck(){
	return T;
    }

    public String getNom(){
	return nom;
    }

    public long getWeight(){
	return need.getWeight();
    }

    


    //accesseur
    
    public void setNom(String n){
	nom = n;
    }

    public void setId(int i){
	this.id=i;
    }

    public void setClient(String cl) {
	this.client = cl;
    }

    public void setNeed(Need B) {
	this.need = B;
    }

    public void setDebut(Date D) {
	this.debut = D;
    }

    public void setFin(Date F) {
	this.fin = F;
    }

    public void setMp(long F){
	need.setMp( F);
    }
    
    public void setWeight(long P){
	this.need.setWeight( P);
    }
    
    public void setPrice(long P){
	need.setPrice( P);
    }


    //Methode associee
    public boolean saveEvent(){
	// cf Jetty

	return true;
    } //TODO


    public boolean compareEvent(Event E) {
	return true;
    } //TODO

    public void printEvent(){
	String buffer = "event: "       + this.ToString()+"\n\n";
	buffer       += "Truck: "       + this.getTruck();
	buffer       += "Client: "      + this.getClient();
	buffer       += "Besoin:\n mp:" + this.getMp()+"\npoids: "+this.getPoids();
	buffer       += "prix: "        + this.getPrix();
	buffer       += "Debut: "       + this.getDebut();
	buffer       += "Fin: "         + this.getFin();
	
		
    } //TODO
    


    //@Override
    public String ToString(){
	return nom;
    }
}
